package cutetd.dao;

import java.util.*;

import cutetd.db.GaeDbBase;
import cutetd.model.M_Goods;

public class GoodsDao extends GaeDbBase{
	
	
	/**
	 * @param goods
	 */
	public void save(M_Goods goods) {
		super.saveOrUpdate(goods);
	}

	public boolean delete(String id) {
		M_Goods t = (M_Goods) super.getObjectByKey(M_Goods.class, id);
		delete(t);
		return true;
	}
	
	/**
	 * @param goods
	 */
	public void update(M_Goods goods) {
		M_Goods g = (M_Goods) super.getObjectByKey(M_Goods.class, goods.getId());
		g = goods;
		super.saveOrUpdate(g);
	}
	/**得到所有导航并按升序返回
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<M_Goods> getListAll() {
		return (List<M_Goods>) super.getListAll(M_Goods.class);
	//	return (List<M_Goods>) super.getListAllByOrder(M_Goods.class, "sort", "asc");
	}
	
	public M_Goods getObjectById(Long id) {
		return (M_Goods) super.getObjectById(M_Goods.class, id);
	}
	
	public M_Goods getObjectByKey(String key) {
		return (M_Goods) super.getObjectByKey(M_Goods.class, key);
	}
	@SuppressWarnings("unchecked")
	public List<M_Goods> getSubList(int start, int end) {
		return (List<M_Goods>) super.getSubList(M_Goods.class, start, end, "id > 1", "id asc");
	}
	
	@SuppressWarnings("unchecked")
	public List<M_Goods> getObjectByKetList(List<String> keys) {
		return (List<M_Goods>) super.getObjectByKeyList(M_Goods.class, keys);
	}
	
	public int getTotalNum() {
		return super.getTotalNum(M_Goods.class);
	}
	
	
}
